package com.ecoolex.chinadutyfree.retailer.core.manager;

import com.ecoolex.chinadutyfree.retailer.core.dao.DirectMailGoodsOrderTotalDataDAO;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderTotalData;
import com.ecoolex.chinadutyfree.retailer.enums.DirectMailGoodsOrderStatus;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DirectMailGoodsOrderTotalDataManager {
    @Autowired
    private DirectMailGoodsOrderTotalDataDAO dao;
    
    /**
     * 订单数据总量统计，定时任务每天执行一次
     */
    public Long orderTotalData(String updateUser) {
    	Date now = new Date();
		return dao.add(DirectMailGoodsOrderStatus.UNPAID.real(), 
			DirectMailGoodsOrderStatus.PAID.real(), 
    		DirectMailGoodsOrderStatus.WAIT_RECECEIVE.real(), 
    		DirectMailGoodsOrderStatus.COMPLETE.real(), 
    		DirectMailGoodsOrderStatus.CANCEL.real(),
    		DirectMailGoodsOrderStatus.AUTO_CANCEL.real(),
    		DirectMailGoodsOrderStatus.AFTER_SALES.real(),
    		DirectMailGoodsOrderStatus.CLOSED.real(),
    		updateUser,now, updateUser,now,DirectMailGoodsOrderTotalData.NOT_DELETED);
    }
    
    /**
     * 获取最新的订单总量数据
     * @return
     */
    public DirectMailGoodsOrderTotalData getLatest() {
    	return dao.getLatest();
    }
}